import java.util.ArrayList;
import java.util.List;

class Solution {
    public List<Integer> path;
    public List<List<Integer>> ret;
    public List<List<Integer>> subsets(int[] nums) {
        path = new ArrayList<>();
        ret = new ArrayList<>();
        dfs(nums, 0);
        return ret;
    }
    private void dfs(int[] nums, int i) {
        if(i == nums.length) {
            ret.add(path);
            return;
        }

        path.add(nums[i]);
        dfs(nums, i+1);
        path.remove(i);

        dfs(nums, i+1);
    }
    private void dfs2(int[] nums, int pos) {
        ret.add(new ArrayList<>(path));
        for(int i = pos; i < nums.length; i++) {
            path.add(nums[i]);
            dfs2(nums, i+1);
            path.remove(path.size()-1);
        }
    }
}